{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 9. Mixture Models and EM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from sklearn.datasets import fetch_mldata\n",
    "%matplotlib inline\n",
    "\n",
    "from prml.clustering import KMeans\n",
    "from prml.rv import (\n",
    "    MultivariateGaussianMixture,\n",
    "    BernoulliMixture\n",
    ")\n",
    "\n",
    "np.random.seed(1111)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 9.1 K-means Clustering"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# training data\n",
    "x1 = np.random.normal(size=(100, 2))\n",
    "x1 += np.array([-5, -5])\n",
    "x2 = np.random.normal(size=(100, 2))\n",
    "x2 += np.array([5, -5])\n",
    "x3 = np.random.normal(size=(100, 2))\n",
    "x3 += np.array([0, 5])\n",
    "x_train = np.vstack((x1, x2, x3))\n",
    "\n",
    "x0, x1 = np.meshgrid(np.linspace(-10, 10, 100), np.linspace(-10, 10, 100))\n",
    "x = np.array([x0, x1]).reshape(2, -1).T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARMAAAD8CAYAAABUzEBbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJztnXd8W9X5/9/P1fRKbMdJnD2dSQYhQNk7BAizQCktu6SllNXCj1FKKeXLaAstBQoEShlllDJTCIEQRggEyN4JcbbjxI7teNua5/fHlRzZlmzZlmxLPu/Xyy9L95579VxL/ujccz7neUQphUa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UBOYHnM74GHgDdE5BpgF3BRq+fRdnqNRhMLkuE2R6PRdAO0mGg0mpigxUSj0cQELSYajSYmaDHRaDQxQYuJRqOJCVpMNBpNTPj/poM8GVz+L8cAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "kmeans = KMeans(n_clusters=3)\n",
    "kmeans.fit(x_train)\n",
    "cluster = kmeans.predict(x_train)\n",
    "plt.scatter(x_train[:, 0], x_train[:, 1], c=cluster)\n",
    "plt.scatter(kmeans.centers[:, 0], kmeans.centers[:, 1], s=200, marker='X', lw=2, c=['purple', 'cyan', 'yellow'], edgecolor=\"white\")\n",
    "plt.contourf(x0, x1, kmeans.predict(x).reshape(100, 100), alpha=0.1)\n",
    "plt.xlim(-10, 10)\n",
    "plt.ylim(-10, 10)\n",
    "plt.gca().set_aspect('equal', adjustable='box')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## 9.2 Mixture of Gaussians"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARMAAAD8CAYAAABUzEBbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJztnXmcVNW1tp9dPVcPgMwKBA3TBYwYuCiKs8HhmnBRMcYYE4PXyI0xzpqYOKBxSJwxJnHAKQISR4wgEj8FjUECXnBAZVRElEERhAaa7n6/P3YXXd19qrqqu6qrullP/86vqs7ZZ59Vpzgve6+99l5OEoZhGM0llGkDDMNoG5iYGIaREkxMDMNICSYmhmGkBBM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JMTAzDSAkmJoZhpAQTE8MwUoKJiWEYKcHExDCMlPD/AVQydAMJBDaqAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "gmm = MultivariateGaussianMixture(n_components=3)\n",
    "gmm.fit(x_train)\n",
    "p = gmm.classify_proba(x_train)\n",
    "\n",
    "plt.scatter(x_train[:, 0], x_train[:, 1], c=p)\n",
    "plt.scatter(gmm.mu[:, 0], gmm.mu[:, 1], s=200, marker='X', lw=2, c=['red', 'green', 'blue'], edgecolor=\"white\")\n",
    "plt.xlim(-10, 10)\n",
    "plt.ylim(-10, 10)\n",
    "plt.gca().set_aspect(\"equal\")\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### 9.3.3 Mixtures of Bernoulli distributions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "mnist = fetch_mldata(\"MNIST original\")\n",
    "x = mnist.data\n",
    "y = mnist.target\n",
    "x_train = []\n",
    "for i in [0, 1, 2, 3, 4]:\n",
    "    x_train.append(x[np.random.choice(np.where(y == i)[0], 200)])\n",
    "x_train = np.concatenate(x_train, axis=0)\n",
    "x_train = (x_train > 127).astype(np.float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABIEAAADjCAYAAAASRQSDAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAH/NJREFUeJzt3VlzVNf9NeCDMfMgkEAS82TAxtgmjuOKq/IJ8qVdvkhVyhUPBMfEx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tjx4/LLEnPuRZaFloam29bau5L81/fBpQtW7aUWRqbqdWvun77tmP2nVNTu1JqOXmXGZv9pbk2NQKlLEnzQN9Wo7Uwf/T9nNO9M6nuBcv9WRmb/aXrIs2N6ZpJbXNbt24tszSnDg8Pl1n1Oy/NVem10vyX1rtp3Zrm23Sea/2e9L+MTX8JBAAAANAAm0AAAAAADbAJBAAAANAAm0AAAAAADbAJBAAAANAAm0AAAAAADVAR/5b0rcNOFYEvXrx4o3N6nfNQ57481GmuLmlMpDrbVHudxlI1pvvWxC4sLJRZurekWsxW7wXG5rshjem1UOvK/8/Y5F2V7lfJarmXGZv9pTVaypJ0PaVq9iStMyvp/NM59v3dm45L6913mYp4AAAAALquswkEAAAA0ASbQAAAAAANsAkEAAAA0ACbQAAAAAANsAkEAAAA0AAV8bCM1GkySN+a2GS1VMiuFcYmrE7GJqxOxubakdaZb3u9uJyvxWAq4gEAAADous4mEAAAAEATbAIBAAAANMAmEAAAAEADbAIBAAAANMAmEAAAAEAD3l/pEwBoncpMAACWwnKuM61p1wZ/CQQAAADQAJtAAAAAAA2wCQQAAADQAJtAAAAAAA2wCQQAAADQAJtAAAAAAA1Yp8YNAAAA4N3nL4EAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGmATCAAAAKABNoEAAAAAGvB/JnyQXFCaRKEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 1440x360 with 5 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "bmm = BernoulliMixture(n_components=5)\n",
    "bmm.fit(x_train)\n",
    "\n",
    "plt.figure(figsize=(20, 5))\n",
    "for i, mean in enumerate(bmm.mu):\n",
    "    plt.subplot(1, 5, i + 1)\n",
    "    plt.imshow(mean.reshape(28, 28), cmap=\"gray\")\n",
    "    plt.axis('off')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
